<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE>
<html>
<head>
<jsp:include page="../header.jsp">
	<jsp:param value="学员缴费" name="title" />
</jsp:include>

<script type="text/javascript" src="static/js/job.js"></script>
<link href="static/css/job_follow.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="static/js/ajax.js"></script>
<script type="text/javascript" src="static/js/total.js"></script>
<script type="text/javascript">

	function feePay() {
		var keyCode = event.keyCode;
		$('#submit').attr("disabled", 'disabled');
		$('#erro').text("");
		var thisPay = parseInt($('#thisPay').val());
		var duePay = parseInt($('#fee').val());
		if ((keyCode >= 48 && keyCode <= 57) || keyCode == 8) {
			if (duePay) {
				if ($('#method').val()) {
					if (thisPay) {
						if (!isNaN($('#thisPay').val())) {
							if (thisPay > duePay) {
								$('#submit').attr("disabled", 'disabled');
								$('#erro').text("缴费金额大于学费！");
							} else {
								$('#submit').removeAttr("disabled");
								$('#erro').text("");
							}
						} else {
							$('#submit').attr("disabled", 'disabled');
							$('#erro').text("只能输入数字！");
						}
					}
				} else {
					$('#erro').text("请选择缴费方式！");

				}
			} else {
				$('#erro').text("请选择学制！");
			}
		} else {
			$('#submit').attr("disabled", 'disabled');
			$('#erro').text("只能输入数字！");
		}

	}

	function feePay1() {
		$('#submit').attr("disabled", 'disabled');
		$('#erro').text("");
		var thisPay = parseInt($('#thisPay').val());
		var duePay = parseInt($('#fee').val());
		if (duePay) {
			if ($('#method').val()) {
				if (thisPay) {
					if (!isNaN(thisPay)) {
						if (thisPay > duePay) {
							$('#submit').attr("disabled", 'disabled');
							$('#erro').text("缴费金额大于学费！");
						} else {
							$('#submit').removeAttr("disabled");
							$('#erro').text("");
						}
					} else {
						$('#erro').text("缴费金额需大于0！");
					}
				} else {
					$('#submit').attr("disabled", 'disabled');
					$('#erro').text("只能输入数字！");
				}
			} else {
				$('#erro').text("请选择缴费方式！");
			}
		} else {
			$('#erro').text("请选择学制！");
		}
	}

	function study(target) {
		if (target.value == 1) {
			$('#fee').attr("value", 30000);
		}
		if (target.value == 2) {
			$('#fee').attr("value", 15000);
		}
		var thisPay = parseInt($('#thisPay').val());
		var duePay = parseInt($('#fee').val());
		if (duePay) {
			$('#erro').text("");
			if ($('#method').val()) {
				if (thisPay) {
					if (!isNaN(thisPay)) {
						if (thisPay > duePay) {
							$('#submit').attr("disabled", 'disabled');
							$('#erro').text("缴费金额大于学费！");
						} else {
							$('#submit').removeAttr("disabled");
							$('#erro').text("");
						}
					} else {
						$('#submit').attr("disabled", 'disabled');
						$('#erro').text("只能输入数字！");
					}
				}
			} else {
				$('#erro').text("请选择缴费方式！");
			}
		}
	}
	function payMethod() {
		var thisPay = parseInt($('#thisPay').val());
		var duePay = parseInt($('#fee').val());
		if (duePay) {
			$('#erro').text("");
			if ($('#method').val()) {
				if (thisPay) {
					if (!isNaN(thisPay)) {
						if (thisPay > duePay) {
							$('#submit').attr("disabled", 'disabled');
							$('#erro').text("缴费金额大于学费！");
						} else {
							$('#submit').removeAttr("disabled");
							$('#erro').text("");
						}
					} else {
						$('#submit').attr("disabled", 'disabled');
						$('#erro').text("只能输入数字！");
					}
				}
			}
		} else {
			$('#submit').attr("disabled", 'disabled');
			$('#erro').text("请选择学制！");
		}
	}
	function pay() {
		if (confirm('确定缴费？')) {
			$('#fee').removeAttr("disabled");
			ShowTip('缴费成功！', $('div.interview.record'));
		}
	}
	function otherPay(){
		var keyCode = event.keyCode;
		$('#submit').attr("disabled", 'disabled');
		var thisPay = parseInt($('#thisPay').val());
		var noPay = parseInt($('#noPay').val());
		if ((keyCode >= 48 && keyCode <= 57) || keyCode == 8) {
					if (thisPay) {
						if (!isNaN($('#thisPay').val())) {
							if (thisPay > noPay) {
								$('#submit').attr("disabled", 'disabled');
								$('#erro').text("缴费金额大于学费！");
							} else {
								$('#submit').removeAttr("disabled");
								$('#erro').text("");
							}
						} else {
							$('#submit').attr("disabled", 'disabled');
							$('#erro').text("只能输入数字！");
						}
					}
		} else {
			$('#submit').attr("disabled", 'disabled');
			$('#erro').text("只能输入数字！");
		}
	}
	
	function otherPay1() {
		$('#submit').attr("disabled", 'disabled');
		$('#erro').text("");
		var thisPay = parseInt($('#thisPay').val());
		var noPay = parseInt($('#noPay').val());
				if (thisPay) {
					if (!isNaN(thisPay)) {
						if (thisPay > noPay) {
							$('#submit').attr("disabled", 'disabled');
							$('#erro').text("缴费金额大于学费！");
						} else {
							$('#submit').removeAttr("disabled");
							$('#erro').text("");
						}
					} else {
						$('#erro').text("缴费金额需大于0！");
					}
				} else {
					$('#submit').attr("disabled", 'disabled');
					$('#erro').text("只能输入数字！");
				}
	}
</script>
</head>
<body>
	<jsp:include page="../menu/menue.jsp"></jsp:include>
	<div class="interview record">
		<form class="ui form" method="post">
			<h4 class="ui dividing header">
				缴费<span style="float: right; font-size: 8px; color: gray;">员工：${emplo.userName}</span>
			</h4>
			<input type="hidden" name=stuId value="${student.id}"> <input
				type="hidden" name=empId value="${emplo.id}">
			<div class="two fields">
				<div class="field">
					<label>名字</label>
					<div class="ui selection dropdown">
						<div class="default text" style="color: black;">${student.name }</div>
					</div>
				</div>
				<div class="field">
					<label>身份证号码</label>
					<div class="ui selection dropdown">
						<div class="default text" style="color: black;">${student.idCard}</div>
					</div>
				</div>
			</div>
			<div class="two fields">
				<div class="field">
					<c:choose>
						<c:when test="${ student.classType==0}">
							<label>学制</label>
							<select class="ui fluid dropdown" onchange="study(this)"
								name="classType">
								<option value="">学制</option>
								<option value="1">高中部</option>
								<option value="2">研发部</option>
							</select>
						</c:when>
						<c:otherwise>
							<label>未缴(元)</label>
							<input value="${stuPayPo.noPay}" style="color: black;"
								disabled="disabled" name="noPay" id="noPay">
						</c:otherwise>
					</c:choose>
				</div>
				<div class="field">
					<label>学费(元)</label>
					<c:choose>
						<c:when test="${student.classType==0}">
							<input id="fee" type="text" name="duePay" disabled="disabled"
								placeholder="学费">
						</c:when>
						<c:otherwise>
							<div class="ui selection dropdown">
								<div class="default text" style="color: black;">${stuPayPo.duePay}</div>
							</div>
						</c:otherwise>
					</c:choose>
				</div>
			</div>
			<div class="two fields">
				<div class="field">
					<label>缴费方式*</label>
					<c:choose>
						<c:when test="${ student.classType==0}">
							<select class="ui fluid dropdown" id="method" name="payWay"
								onchange="payMethod()">
								<option value="">缴费方式</option>
								<option value="1">贷款</option>
								<option value="2">现清</option>
							</select>
						</c:when>
						<c:otherwise>
							<div class="ui selection dropdown">
								<div class="default text" style="color: black;">${stuPayPo.payWayText}</div>
							</div>
						</c:otherwise>
					</c:choose>
				</div>
				<div class="field">
					<label>本次缴费*(元)</label> <input type="text" id="thisPay"
						style="ime-mode: disabled;" name="thisPay"
						onkeyup="${empty stuPayPo.pId ? 'feePay()':'otherPay()'}"
						onchange="${empty stuPayPo.pId ? 'feePay1()': 'otherPay1()'}"
						value="${param.thisPay }" placeholder="本次缴费">
				</div>
			</div>
			<button class="ui button" tabindex="0" type="submit"
				disabled="disabled" id="submit" style="text_align: center;"
				onclick="pay()">缴费</button>
			<a class="ui button" tabindex="0" id="cancel" href="student/haventpay"
				>取消</a> <span class="erro" id="erro">${erro}</span>
		</form>
	</div>
</body>
</html>